package com.dpl.yyrj.ui.data;


import android.view.View;

import androidx.appcompat.widget.AppCompatEditText;
import androidx.appcompat.widget.AppCompatTextView;

import com.dpl.yyrj.R;
import com.dpl.yyrj.utils.LogUtil;

/**
 * @author dpl
 * @date: 2025/8/2 星期六 16:11
 * @description
 **/
public class ViewAndTag {
    private View view;
    private String tag;

    private AppCompatTextView includeEdittext;
    private final static int includeEdittextId = R.id.tv_content_value;

    private View.OnClickListener onClickListener;
    private View.OnClickListener onClickListenerInput;

    private AppCompatTextView includeText;
    private final static int includeTextId = R.id.tv_content_time;

    public final static String TAG = "ViewAndTag";

    public ViewAndTag(View view, String tag) {
        this.view = view;
        this.tag = tag;
    }

    public View getView() {
        return view;
    }

    public void setView(View view) {
        this.view = view;
    }

    public String getTag() {
        return tag;
    }

    public void setTag(String tag) {
        this.tag = tag;
    }

    public AppCompatTextView getIncludeEdittext() {
        if (getView() == null ) {
            LogUtil.w(TAG, "getIncludeEdittext views is null or views.size() <= i");
            return null;
        }
        if (includeEdittext == null) {
            includeEdittext = (AppCompatTextView) getView().findViewById(includeEdittextId);
        }
        return includeEdittext;
    }

    public AppCompatTextView getIncludeText() {
        if (getView() == null) {
            LogUtil.w(TAG, "getIncludeText views is null or views.size() <= i");
            return null;
        }
        if (includeText == null) {
            includeText = (AppCompatTextView) getView().findViewById(includeTextId);
        }
        return includeText;
    }

    public void setIncludeTextClickListener() {
        if (includeText == null) {
            LogUtil.w(TAG, "setIncludeTextClickListener includeText is null");
            return;
        }
        if (onClickListener == null) {
            onClickListener = new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    LogUtil.d(TAG, "includeText click");
                }
            };
            includeText.setOnClickListener(onClickListener);
        } else {
            LogUtil.w(TAG, "setIncludeTextClickListener onClickListener is not null");
        }
    }

    public void setIncludeEdittextClickListener() {
        if (includeEdittext == null) {
            LogUtil.w(TAG, "setIncludeEdittextClickListener includeEdittext is null");
            return;
        }
        if (onClickListenerInput == null) {
            onClickListenerInput = new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    LogUtil.d(TAG, "includeEdittext click");
                }
            };
            includeEdittext.setOnClickListener(onClickListenerInput);
        } else {
            LogUtil.w(TAG, "setIncludeEdittextClickListener onClickListenerInput is not null");
        }

    }
}
